use serde::{Deserialize, Serialize};

use super::{Input, Output, NodeTrait};

#[derive(Serialize, Deserialize, Clone)]
pub struct RootNode {
    output:Vec<Output>
}

impl RootNode {
    pub fn new()->Self {
        Self {
            output: vec![Output {
                name: "Root".to_string(),
                description: Some("子节点".to_string()),
                value: crate::graph::value::Value::Node
            }]
        }
    }
}

impl NodeTrait for RootNode {
    fn name(&self) ->  &str {
        "Root"
    }

    fn ty(&self) ->  &str {
        "__ROOT_NODE__"
    }

    fn description(&self) -> Option<&str> {
        Some("根节点")
    }

    fn inputs(&self) ->  &[Input] {
        &[]
    }

    fn outputs(&self) ->  &[Output] {
        &self.output
    }

    fn has_children(&self) -> bool {
        true
    }

    fn inputs_mut(&mut self) ->  &mut Vec<Input> {
        panic!("RootNode has no inputs")
    }

    fn outputs_mut(&mut self) ->  &mut Vec<Output> {
        &mut self.output
    }

    fn children_count(&self) -> Option<usize> {
        Some(1)
    }

    fn can_copy(&self)->bool {
        false
    }

    fn can_delete(&self)->bool {
        false
    }
}
